package com.example.administrator.myapplication;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.support.annotation.Nullable;

/**
 * Created by Administrator on 2018/1/3.
 */

public class Alarm extends Activity {

    private MediaPlayer mediaPlayer;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        setContentView(R.layout.alarm);
        super.onCreate(savedInstanceState);
        mediaPlayer = MediaPlayer.create(Alarm.this,ActivityManager.getUri());
        mediaPlayer.setVolume(300,350);
        mediaPlayer.setLooping(true);
        mediaPlayer.start();
        Intent intent  = getIntent();
        String messageTitle = intent.getStringExtra("messageTitle");
        String massageContent = intent.getStringExtra("messageContent");

        AlertDialog.Builder adb = new AlertDialog.Builder(Alarm.this);
        adb.setTitle(messageTitle);
        adb.setMessage(massageContent);
        adb.setPositiveButton("确定", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
              mediaPlayer.stop();
              mediaPlayer.release();
              finish();
            }
        });
        adb.show();
    }
}
